<?php
namespace Home\Controller;
use Think\Controller;
use Common\Utils\Revenue;
use Common\Utils\SysFile;
use Common\Utils\DataImport;
//数据导入控制器
class DataImportController extends Controller {
	public function csvTomysql()
	{
		$data_obj=new Revenue();
		$data_obj->moreFileToMysql();
		$data_obj->noFindCompayLog();

	}


	public function upMssqlComid()
	{
		$data_obj=new Revenue();
		$data_obj->upMssqlComid();
	}

	public function dataToMssql()
	{
		$data_obj=new Revenue();
		$data_obj->dataToMssql();
	}



	public function newDataToMySql()
	{
		dump_r("开始导入数据.");
		$path=dirname(__FILE__).'\\..\\..\\..\\excel_files\\';
		
		$file_obj= new SysFile();
		$file_rows=$file_obj->getFileList($path);

		foreach ($file_rows as $file) {

			try {
				$dataimport_obj=new DataImport($path.$file);
				
				$dataimport_obj->checkComCache();

				$dataimport_obj->toMysql();

				$dataimport_obj->toMssql();

				$dataimport_obj->getImportResult();

				$file_obj->setFileOver($path.$file);

			} catch (\Think\Exception $e) {
				dump_r($e->getMessage());
			}
		}




		dump_r("导入数据完毕.");
		
	}

}